import axios from 'axios'

// response 拦截器
axios.interceptors.response.use(
  response => {
    return response.data
  },
  error => {
    return Promise.reject(error)
  }
)

// ? 生产路径
// export const baseUrl = "https://mapi.51healthinfo.com/mall"
// export const baseUrlHealth = "https://api.51healthinfo.com/health"
// export const baseShowImg = 'https://mapi.51healthinfo.com'
// const baseImg = 'https://mapi.51healthinfo.com/mall/uploadImgServlet'
// const HelpImg = 'https://mapi.51healthinfo.com/mall/uploadHelpFileServlet'
// export const baseMpage = "https://mweb.51healthinfo.com/mpage/service/#/homepage"

// ? 测试环境
export const baseUrl = 'http://test.51healthinfo.com/mall'
export const baseUrlHealth = 'http://test.51healthinfo.com/health'
export const baseShowImg = 'http://test.51healthinfo.com'
const baseImg = 'http://test.51healthinfo.com/mall/uploadImgServlet'
const HelpImg = 'http://test.51healthinfo.com/mall/uploadHelpFileServlet'
const FileImg = 'http://test.51healthinfo.com/mall/newUploadHyalineFileServlet'
export const baseMpage = 'http://test.51healthinfo.com/mpage/service/#/homepage'
// 助老图片上传
export const helpOldImg = (data) => {
  return axios.post(HelpImg, data)
}

//图片透明化百分之50   两个功能：上传指纹图片   将黑色指纹变为红色
export const finImg = (data) => {
  return axios.post(FileImg, data)
}

// 图片上传
export const uploadImgs = (data) => {
  return axios.post(baseImg, data)
}

// 视频上传
export const uploadVideo = (data) => {
  return axios.post(baseUrl + '/uploadVideo', data)
}

// 商城系统公用接口
export const mall = (controllerName, service, serviceData) => {
  return axios.post(baseUrl + controllerName, JSON.stringify({
    mobilet: 'weixin',
    clientName: '新融邻帮',
    clientver: '2.0.1',
    screenSize: '375x812',
    macAddress: "",
    userID: sessionStorage.getItem('userID') || '',
    busiData: {
      handleSessionLost: "false",
      timeOut: "30000",
      service,
      token: "",
      operCode: sessionStorage.getItem('opercode'),
      operType: '1',
      serviceData,
    }
  }))
}

// 健康系统公用接口
export const health = (controllerName, service, serviceData) => {
  return axios.post(baseUrlHealth + controllerName, JSON.stringify({
    mobilet: 'weixin',
    clientName: '新融邻帮',
    clientver: '2.0.1',
    screenSize: '375x812',
    macAddress: "",
    userID: sessionStorage.getItem('userID') || '',
    busiData: {
      handleSessionLost: "false",
      timeOut: "30000",
      service,
      token: "",
      operCode: sessionStorage.getItem('opercode'),
      operType: '1',
      serviceData,
    }
  }))
}